package com.itheima.redisTest;

import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.Set;

/*
*   Jedis功能测试
* */
public class RedisDemo02 {
    public static void main(String[] args) {
        //创建连接对象
        Jedis jedis = new Jedis("192.168.120.129",6381);
        //执行操作
        //根据索引选择数据库
        String select = jedis.select(3);
        System.out.println(select);
        //添加键值数据
        jedis.set("name","aunero");
        System.out.println(jedis.get("name"));
        //添加list数据  栈结构  数据可重复
        jedis.lpush("list1","a","b","c","d","e");
        List<String> list1 = jedis.lrange("list1", 0, -1);
        System.out.println(list1);
        //添加set数据  队列结构 数据不可重复
        jedis.sadd("set1","abc","edf","ghi","jkl");
        Set<String> set1 = jedis.smembers("set1");
        System.out.println(set1);
        //关闭连接
        jedis.close();
    }
}
